import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// @ts-ignore - 类型声明缺失但包已安装
import AutoImport from 'unplugin-auto-import/vite'
// @ts-ignore - 类型声明缺失但包已安装
import Components from 'unplugin-vue-components/vite'
// @ts-ignore - 类型声明缺失但包已安装
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  base: './',
  plugins: [
    vue(),
    AutoImport({
      resolvers: [
        ElementPlusResolver(),
      ],
    }),
    Components({
      resolvers: [
        ElementPlusResolver(),
      ],
      dts: true,
    }),
  ],
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:8080',
        changeOrigin: true,
        rewrite: (path) => path,
      },
    },
  },
  resolve: {
    alias: {
      '@': '/src',
    },
  },
})
